package pri.zjy.linkedList;

import pri.zjy.linkedList.model.ListNode;

/**
 * @author zhangjy
 * @description 环形链表
 * @date 2025/6/1 23:54
 */
public class hasCycle_141 {

    public boolean hasCycle(ListNode head) {
        if (head == null) return false;

        ListNode slow = head;
        ListNode fast = head;
        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
            if (slow == fast) return true;
        }

        return false;
    }

}
